home *** CD-ROM | disk | FTP | other *** search
/ WINMX Assorted Textfiles / Ebooks.tar / Text - Tech - Electronics - Magnetic Card Swipe Reader (TXT).zip / Magnetic Card Swipe Reader.txt
Text File  |  2002-10-30  |  17KB  |  522 lines

  1.  
  2. Summary of replies to the following request:
  3.  
  4. Subject: Mag Card Swipe Reader: Need Help!
  5.  
  6. Hello, Everybody.
  7.  
  8. I just picked up one of those swipe readers for mag stripes on credit
  9. cards etc. from a surplus outfit (American Science & Surplus in
  10. Evanston, IL  708/475-8440 for those who are interested). It's not the
  11. complete unit with keypad, display, etc. but rather just the guts of the
  12. subassembly which actually reads the card (hey, what do you expect for
  13. $2.50?? ;-) Since it's surplus and taken out of a larger piece of
  14. equipment, I have no docs for this sucker. My hope is that someone else
  15. picked up one of these things to play with and has some docs or has figured
  16. out enough about it to get it to work, OR can tell me who to contact to get
  17. more info on this beast. I figured this would be a good place to ask
  18. since I've seen people asking about swipe card readers recently.
  19.  
  20. Anyway, here's a description:
  21. The unit is about 6" long, 1" wide, and maybe 2" high. It consists of a
  22. metal backing plate, attached to which is a black plastic guide channel
  23. through which you swipe the card. On one side of the plastic channel is a
  24. read head for the mag stripe; on the opposite side is a small printed circuit
  25. board.
  26.  
  27. Removing the plastic guide from the mounting plate reveals that the
  28. manufacturer is SR&D corporation of Tokyo, Japan. The model number is
  29. MCR-175-1R-0803; a serial number is also listed. The SR&D logo-lettering
  30. appears on the component side of the PC board, and on the foil side of
  31. the board the SR&D is repeated along with the code "FNC -065-1" in the
  32. upper right hand corner. The board has one IC on it (I can't easily see
  33. what the numbers are on this chip, so I'm not sure what kind it is other
  34. than a 16 pin DIP). There is a spot for another chip, an 8-pin DIP for
  35. which the screened label reads "IC2 6914", but this chip and some other
  36. resistors, capacitors, etc. are missing.
  37.  
  38. Finally, there are 5 wires coming from the assembly and terminating in a
  39. small connector similar to power supply connectors for 3.5" floppy drives.
  40. The wires are red, yellow, green, blue, and black.
  41.  
  42. I haven't hacked on this thing at all yet, since I don't know what its
  43. power requirements are or even which are power leads and which are data
  44. leads. If anyone has any information on this puppy which might help me,
  45. I'd love to hear from you! Please email me. I'll share whatever I find
  46. out with anyone who's interested.
  47.  
  48. Thanks!
  49.  
  50. ---
  51.  
  52. [Editor's Note: The following is a concatenation of the replies I received
  53. to the net.request above. After the replies I have included information
  54. which was posted to the net on how mag stripe cards are encoded (in case
  55. anyone missed it). Finally, I have included some software that I threw
  56. together to play with the card reader. This file contains all the information
  57. I have on this subject. Additions are most welcome.
  58.  
  59. You'll notice I didn't get any farther than simply reading the raw signal
  60. from the card; of the two card readers I ordered, one was completely DOA,
  61. and the other had a faulty clock output (at least I assume that it was a
  62. clock output; I was never able to read any sort of signal from that line).
  63. Someone with a fully functional reader can easily extend what I wrote to get
  64. it to decode the actual data content of the card. If you do decide to make
  65. modifications and/or extensions, I'd appreciate a copy of whatever
  66. changes you make (email to tmkk@uiuc.edu).  Enjoy!]
  67.  
  68.  
  69. Subject: Re: Mag Card Swipe Reader: Need Help!
  70.  
  71. I am truly amazed that someone else is trying to use this device!  I got
  72. mine about 2 years ago and spent some time trying to find the manufacturer.
  73. I found a listing for SR&D in the Noth America technical directory at 
  74. the public library.  I found the listing for the American sales office
  75. in Los Angeles.  I tried calling but the company had gone out of 
  76. business.  There was no listing in the local phone directory either.
  77. I then tried calling the head office in Japan, but they also had
  78. gone out of business.  I haven't seen the company listed in any recent
  79. electronics directories, so I think they really are gone.
  80.  
  81. I have spent about an hour looking at the signals on the outputs
  82. of the device.  One signal line is a /STATUS line which indicates
  83. when a card is been moved through the unit.  The other 2 lines
  84. pulse in response to a magnetic card.  I believe the IC performs
  85. Manchester decoding and clock recovery for the read channel, so one
  86. output line is DATA and the other is CLOCK.  
  87.  
  88. That is as far as I got 2 years ago and I had forgot about it until
  89. now.  If you receive any other info, please send a copy to me!
  90.  
  91. ---
  92.  
  93. >Finally, there are 5 wires coming from the assembly and terminating in a
  94. >small connector similar to power supply connectors for 3.5" floppy drives.
  95. >The wires are red, yellow, green, blue, and black.
  96.  
  97. If its anything like the units I worked with, I think you  will find
  98. that the five wires are:
  99.  
  100.         +5v
  101.     Gnd
  102.     Clock
  103.     Data
  104.     Card detected
  105.  
  106. But I don't know active levels, or which wire is what.
  107.  
  108. ---
  109.  
  110. I picked few week ago a magnetic credit card reader from a 
  111. another surplus outfit. It cost about the sam es yours. 
  112. My card reader was made by MAGTEK and was diffrent from
  113. your reder in many ways. The reader I have has 4 ICs and
  114. some of them are standard TTL chip, so I could easily 
  115. quess the power requiments (5V) and power connectors.
  116. My card reader had 6 pin connector. 
  117. I put the power to the reader and started to examine 
  118. the signals with multimeter and a little crystal
  119. earphine (my favourite electronics hacking tool).
  120. I found that output signals were something like
  121. that: data out, data clock out, data readable and
  122. and card ath the end of the reader.
  123. Then I connected the reader to the joystick port
  124. of my 386SX and made a little Turbo Pascal program
  125. for reading the card.
  126.  
  127. Spare printer port is the interface I use very often to connect
  128. diffrent hardware circuit to my computer. This time I decided
  129. to use game port beacuse it can also provide the power to the
  130. reader.
  131.  
  132. My program simply prints out the bits from the card. I have not
  133. found the way to decode the bits to corresponding numbers. The
  134. program so prints all 237 bits form the card to screen.
  135. If you have any information about data coding, I an interrested
  136. in hearing that.
  137.  
  138. Here is the meanings of the bytes in port $201:
  139. D7: 0 -> card pushed to the end of the reader
  140. D6: the read data from card
  141. D5: 0 -> data stream readable
  142. D4: the data clock
  143.  
  144. Program CardReader;
  145.  
  146. Uses Crt,Binary;
  147.  
  148. Const
  149.    gameport=$201;
  150.  
  151.  
  152. Procedure Wait_start;
  153. Begin
  154.    Repeat Until (Port[gameport] and 32)=0;
  155. End;
  156.  
  157. Function data_readable:boolean;
  158. Begin
  159.    data_readable:=((Port[gameport] and 32)=0);
  160. End;
  161.  
  162. Procedure Wait_clock;
  163. Begin
  164.    Repeat Until (Port[gameport] and 16)=0;
  165. End;
  166.  
  167. Procedure Wait_clock_end;
  168. Begin
  169.    Repeat Until (Port[gameport] and 16)=16;
  170. End;
  171.  
  172. Function data_input:byte;
  173. Begin
  174.    If (Port[gameport] and 64)=0 Then data_input:=0
  175.       Else data_input:=1;
  176. End;
  177.  
  178. Function card_at_end:boolean;
  179. Begin
  180.    card_at_end:=((Port[gameport] and 128)=0);
  181. End;
  182.  
  183. Procedure test;
  184. Begin
  185.    Wait_start;
  186.    Repeat
  187.       Writeln(ByteBin(Port[$201]));
  188.    Until keypressed;
  189. End;
  190.  
  191. Begin
  192.    ClrScr;
  193.    Wait_start;
  194.    While data_readable Do Begin
  195.       Wait_clock;
  196.       Write(data_input);
  197.       Wait_clock_end;
  198.    End;
  199.    Repeat Until KeyPressed;
  200. End.
  201.  
  202. ---
  203.  
  204. Wiring color code for the SR&D MCR-175-1R-0803 mag stripe card reader:
  205.  
  206.    Red:         +5V
  207.  Black:         Gnd
  208. Yellow:         /Card Detect
  209.  Green:         Clock (?? - non-functional on the unit I have)
  210.   Blue:         /Data
  211.  
  212.  
  213. The leading '/' indicates an active low TTL signal.
  214.  
  215.  
  216. ---
  217.  
  218.            Quick 'n Dirty guide to the enclosed reader software
  219.            ----------------------------------------------------
  220.  
  221. Hooking the SR&D MCR-175-1R-0803 card reader to your PC:
  222.  
  223. The included software is written specifically for the following
  224. configuration; if your wiring is different, you'll need to make
  225. corresponding changes to the software. Note also that the port
  226. address is hard-coded to look for LPT2's status port (at address
  227. 0x279). If you're using a different port address, be sure to change the
  228. port address value.
  229.  
  230. SR&D Wire       Printer Port Pin        Port Bit        Signal
  231. ---------       ----------------        --------        ------
  232. Yellow          11                      7               /CARD DETECT
  233. Blue            10                      6               /DATA
  234. Black           18                      N/A             (Ground)
  235.  
  236. Power to the reader was provided by a separate power supply, basically
  237. one of those black plastic DC power packs fed through a 7805 regulator
  238. chip.
  239.  
  240.  
  241. Compiling the software:
  242.  
  243. Compile SWIPE.C (using SMALL memory model), assemble SWIPEISR.ASM, and
  244. link the two together.
  245.  
  246.  
  247. Using the software:
  248.  
  249. To use SWIPE.EXE, simply hook the reader up to your LPT2: port, power it
  250. up, then run SWIPE. When you're ready, press the ENTER key, and swipe a
  251. card through the reader. The program will read the data from the card and
  252. store it in a buffer (but will not decode the data; that is left as an
  253. excercise ;-). After the card has been read, press ENTER again and the
  254. contents of the buffer will be dumped to stdout. To save the card data to
  255. a file, simply redirect SWIPE's output on the command line, e.g.
  256.  
  257. SWIPE > citibank.out
  258.  
  259. Please let me know of any changes, bug fixes, or improvements you make to
  260. this code. Send email to tmkk@uiuc.edu.
  261.  
  262. Thanks, and have fun!
  263.  
  264. --- CUT HERE ---
  265.  
  266. /*
  267.  * S W I P E . C
  268.  *
  269.  * Written:
  270.  *     1/11/92
  271.  *
  272.  * Description: Quick 'n Dirty reader program for SR&D mag stripe card reader.
  273.  *     Reads data from the input port as long as a card is detected in the
  274.  *     card slot. After sampling, the data is dumped to stdout, and may
  275.  *     be redirected to a file if desired.
  276.  *
  277.  * Note: Written for Borland C++ 3.0 - may require changes to compile under
  278.  *     MSC or others. Compile in SMALL model.
  279.  *
  280.  */
  281.  
  282. #include <stdio.h>
  283. #include <conio.h>
  284. #include <process.h>
  285. #include <dos.h>
  286. #include <math.h>
  287. #include <stdlib.h>
  288. #include <assert.h>
  289. #include <string.h>
  290.  
  291. /* timer chip programming register port addresses */
  292. #define COMMAND_REG 0x43#define CHANNEL0 0x40
  293.  
  294. /* size of sample buffer */
  295. #define MAXSAMPLE 4096
  296.  
  297. typedef unsigned char byte;
  298.  
  299.  
  300. /* global variables */
  301. byte *databuf;  /* buffer for the sampled data */
  302.  
  303. /* interprocess communication data */
  304. byte *bufp;         /* data buffer pointer */
  305. unsigned nsamp;     /* number of samples to be made */
  306. unsigned port;      /* input port address */
  307. int enab=0;         /* flag to enable/disable sampling */
  308. int start=0;        /* flag indicating that sampling has begun */
  309.  
  310. /* ISR prototype */
  311. extern void interrupt shand(void);
  312.  
  313.  
  314. void program_timer(int channel, unsigned count)
  315. /*
  316.  * P R O G R A M _ T I M E R
  317.  *
  318.  * Description: Programs the given count value into the specified channel of
  319.  *     the IBM 825x timer chip. Channel 0 is the time-of-day-clock interrupt;
  320.  *     channel 2 is the speaker pulser.
  321.  *
  322.  * Parameter:
  323.  *     channel (in) - Channel to be programmed.
  324.  *     count (in) - Count value with which to program timer chip.
  325.  *
  326.  */
  327. {
  328.  
  329.     outportb(COMMAND_REG, 0x36);  /* set up for reprogramming */
  330.     outportb(CHANNEL0 + channel, count & 0xff);  /* lo byte first */
  331.     outportb(CHANNEL0 + channel, count >> 8);  /* then hi byte */
  332. }
  333.  
  334. void sample_data(int count)
  335. /*
  336.  * S A M P L E _ D A T A
  337.  *
  338.  * Description: Sets up for data collection from the printer port using
  339.  *     the SHAND interrupt service routine (see SWIPEISR.ASM). This routine
  340.  *     reprograms the timer chip for the desired sampling rate, sets up
  341.  *     the interprocess communication area, and starts the sampling process.
  342.  *     The actual sampling is done in the SHAND procedure. This routine
  343.  *     waits until sampling has been completed before returning.
  344.  *
  345.  */
  346. {
  347. void interrupt (*oldhand)(void);  /* pointer to old interrupt vector */
  348.  
  349.     /* save old interrupt vector */
  350.     oldhand = getvect(0x1c);
  351.  
  352.     /* clear enable flag */
  353.     enab = 0;
  354.     start = 0;
  355.  
  356.     /* install new vector */
  357.     setvect(0x1c, shand);
  358.  
  359.     /* set up interprocess communications area */
  360.     nsamp = 0;
  361.     bufp = databuf;
  362.     port = 0x279;  /* address of printer status register */
  363.  
  364.     cprintf("Sampling at %fHz (= %fms)....",
  365.        1193180.0 / (float)count, (float)count / 1193.18);
  366.  
  367.     /* reprogram timer chip */
  368.     program_timer(0, count);
  369.  
  370.     /* enable sampling */
  371.     enab = 1;
  372.  
  373.     /* wait until sampling is completed */
  374.     while (enab) ;
  375.  
  376.     /* restore standard timing value */
  377.     program_timer(0, 0);
  378.  
  379.     /* reinstall old handler vector */
  380.     setvect(0x1c, oldhand);
  381.  
  382.     cprintf(" completed.\r\n");
  383.  
  384. }
  385.  
  386.  
  387. void main()
  388. {
  389. unsigned i;
  390.  
  391.     /* allocate memory */
  392.     databuf = calloc(MAXSAMPLE, sizeof(byte));
  393.     assert (databuf != NULL);
  394.  
  395.     cprintf("Press <ENTER> when ready to swipe card:");
  396.     getchar();
  397.     sample_data(12);  /* This works out to about a 100kHz sampling rate  */
  398.  
  399.     cprintf("Sampling completed, %u samples total.\r\n", nsamp);
  400.     cprintf("Press <ENTER> to dump data.\r\n\r\n");
  401.     getchar();
  402.  
  403.     /* dump data to stdout */
  404.     for (i=0; i<nsamp; ++i)
  405.     if (kbhit())
  406.         break;
  407.     else
  408.         printf("%u\n", databuf[i]);
  409.  
  410.     free (databuf);
  411.  
  412. }
  413.  
  414. --- CUT HERE ---
  415.  
  416. ;
  417. ; S W I P E I S R . A S M
  418. ;
  419. ; Interrupt Service Routine to sample swipe reader.\*
  420. ;_TEXT   segment byte public 'CODE'
  421. DGROUP    group    _DATA,_BSS
  422.     assume    cs:_TEXT,ds:DGROUP,ss:DGROUP
  423. _TEXT    ends
  424.  
  425. _DATA    segment word public 'DATA'
  426. ; Nuthin' in here!
  427. _DATA   ends
  428.  
  429. _BSS    segment word public 'BSS'
  430. ; Nuthin' in here either!
  431. _BSS    ends
  432.  
  433. _TEXT    segment    byte public 'CODE'
  434. ;
  435. ; S H A N D
  436. ;
  437. ; Description: Sample interrupt handler for timer extension interrupt 0x1c.
  438. ;
  439. ; Note: Assumes that the /CARD DETECT line appears on bit 7 of the input
  440. ;     port. This bit corresponds to pin 11 on the standard PC printer port.
  441. ;     Also, the PC printer port card inverts the signal on this pin; thus,
  442. ;     bit 7 is *set* when a card is in the reader, even though /CARD DETECT
  443. ;     is an active low signal.
  444. ;
  445. _shand    proc    far
  446.     push    ax
  447.     push    bx
  448.     push    dx
  449.     push    ds
  450.     push    si
  451.     push    di
  452.     push    bp
  453.     mov    bp,DGROUP
  454.     mov    ds,bp
  455.  
  456.        cmp     word ptr DGROUP:_enab, 0                ; Are we turned on?
  457.         je      ciao                                    ; Nope - goodbye!
  458.  
  459.         mov     dx, word ptr DGROUP:_port               ; Get port address
  460.         cmp     word ptr DGROUP:_start, 0               ; Has sampling begun?
  461.         jne     doit                                    ; Yup - hop to it!
  462.  
  463. ;
  464. ; Sampling is enabled but has not actually begun because no card has yet been
  465. ;     detected in the slot of the reader. Check to see if a card has arrived
  466. ;     yet and, if it has, set the flag to indicate that sampling should begin.
  467. ;
  468.         in      al, dx                                  ; sample port
  469.         test    al, 80h                                 ; card detected?
  470.         jz      ciao                                    ; nope - later!
  471.  
  472.         mov     word ptr DGROUP:_start, 1               ; card's there,
  473.                                                         ; start reading it
  474.         jmp     saveit
  475. ;
  476. doit:
  477.         in      al, dx                                  ; Read the port
  478.         test    al, 80h                                 ; card detect bit set?
  479.         jz      disable                                 ; if not, quit
  480. ;
  481. ; Data is still valid; get buffer pointer and save the data
  482. ;
  483. saveit:
  484.         mov     bx,word ptr DGROUP:_bufp                ; get addr. to write
  485.         mov     byte ptr [bx],al                        ; save sampled value
  486.         inc     word ptr DGROUP:_bufp                   ; and bump the ptr
  487.  
  488.         inc     word ptr DGROUP:_nsamp                  ; update sample count
  489.         jmp     ciao                                    ; and skeedaddle
  490.  
  491. disable:
  492.         mov     word ptr DGROUP:_enab,0                 ; card no longer
  493.                                                         ; detected - disable
  494.                                                         ; sampling
  495. ciao:
  496.         pop     bp                                      ; restore context
  497.     pop    di
  498.     pop    si
  499.     pop    ds
  500.     pop    dx
  501.     pop    bx
  502.     pop    ax
  503.     iret    
  504. _shand    endp
  505. _TEXT    ends
  506.  
  507. _DATA    segment word public 'DATA'
  508. ;s@      label   byte
  509. _DATA    ends
  510.         extrn   _nsamp:word
  511.     extrn    _port:word
  512.     extrn    _bufp:word
  513.     extrn    _enab:word
  514.         extrn   _start:word
  515. _TEXT    segment    byte public 'CODE'
  516.     extrn    _inportb:near
  517. _TEXT    ends
  518.     public    _shand
  519.     end
  520.  
  521. === END OF SUMMARY ===
  522.